package cate.game.train.rune.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTrain;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title=  "英雄脱徽章の 请求")
@OperationSetter(GDOperation.RUNE_OFF)
public class RuneOffReq implements MsgInput {
    @NoteField(value = "英雄UID")
    public String heroUid;

    @NoteField(value = "部位ID", detail = "要脱的部位")
    public byte pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        Hero hero = cc.getRole().getBag().hero.getItem(heroUid);
        if(hero == null){
            game.notice.message(cc.getRole(),"英雄不存在");
            return;
        }
        EcResult r = hero.offRune(game.fight.getPlayBuildContext(), pos);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
            return;
        }
        cc.sendNow(new RuneOffResp(heroUid, pos));
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTrain.HERO_RUNE_OFF_REQ;
    }
}
